<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
$return=array();
if($_RQ['op']=='main'){
	$return['list']=array();
	$return['params']=array('type'=>1,'tstart'=>'2021-01-01','tend'=>date('Y-m-d'));
	$return['intype']=$this->intype;
	$this->model('model')->checkquan('jy_shopwms/manage.in_log/');
	exi($return);
}
//声明列表页
if($_RQ['op']=='list'){
	//初始化返回前端的筛选条件数组
	$return['params']=array('type'=>1);
	//整理列表数据查询条件
	$params=array('store_id'=>$this->store_id,'uniacid'=>$_SESSION['uniacid'],'type'=>1);
	if($_RQ['goods_id']){
		$params['goods_id']=intval($_RQ['goods_id']);
		$return['params']['goods_id']=$_RQ['goods_id'];
	}
	//创建时间
	if($_RQ['appstart']){
		$tstart=strtotime($_RQ['appstart']);
	}else{
		$tstart=$_RQ['newtstart']?:0;
	}
	if($_RQ['apptend']){
		$tend=strtotime($_RQ['apptend']);
	}else{
		$tend=$_RQ['newtend']?:TIMESTAMP;
	}
	$params['createtime between']=array($tstart,$tend);
	$psize=10;
	$pindex=intval($_RQ['page'])?:1;
	$parameter=array(
		'params'=>$params,
		'limit'=>array($pindex,$psize),
		'orderby'=>'id desc',
	);
	//执行分页查询
	$list=$this->get_list('log',$parameter,$total);
	if($list){
		foreach($list as &$item){
			if($item['goodstype']==1){
				$item['goods']=$this->pdo_get('goods',array('id'=>$item['goods_id']),array('title','image'));
			}else{
				$item['goods']=pdo_get('jy_weishop_goods',array('id'=>$item['goods_id']),array('title','image'));
			}
			$item['goods']['image']=tomedia($item['goods']['image']);
			$item['member']=cfc('core')->member_show($item['mid']);
			$item['typetitle']=$this->intype[$item['intype']];
		}
	}
	//将查询到的结果数组放入$return以备传回前端
	$return['list']=$list;
	//把数据返回前端
	exi($return);
}